<?php

// Выводим введенную информацию.

print '<br /><h3>Другие участники</h3>';

if ( ! count( $members ) )
{
  print '<p><i>Нет участников.</i></p>';
}
else
{
  $view = array(
    'pending'     => 'Член группы проверяется',
    'approved'    => 'Член группы принят',
    'disapproved' => 'Член группы не принят',
  );

  print '<table>';

  foreach ( $members as $member )
  {
    $member = cleaner( $member );
    
    ?>
    <tr>
    
      <?php if ( $request['status'] <> 'new' ) { ?>    
      <td width='46' style='text-align: center'><img src='/images/status/<?php print $member['status'] ?>.png' height='24px' title='<?php print $view[ $member['status'] ] ?>' alt='<?php print $view[ $member['status'] ] ?>'></td>
      <?php } ?>                  
    
      <td class="member">
        <?php print $member['nickname'] ?> (<?php print $member['name'] ?>), <?php print $member['city'] ?><br />
        <?php if ( $topic['characters_enabled'] ) print "{$member['character']} ({$member['fandom']})" ?>
      </td>
      
      <td>
        <form action='' method='post'>
          <input type='hidden' name='do' value='delete-member'>
          <input type='hidden' name='id' value='<?php print $member['id'] ?>'>
            
          <button type='submit'>Удалить</button>
                        
        </form>        
      </td>                
      <?php if ( org::$id ) { ?>
      <td style='text-align:left; padding:10px;'>
        <form action='' method='post'>
          <input type='hidden' name='do' value='member-approved'>
          <input type='hidden' name='id' value='<?php print $member['id'] ?>'>
            
          <button type='submit'>Принять</button>
                        
        </form>        
        <form action='' method='post'>
          <input type='hidden' name='do' value='member-disapproved'>
          <input type='hidden' name='id' value='<?php print $member['id'] ?>'>
            
          <button type='submit'>Отклонить</button>
                        
        </form>        
      </td>                
      <?php } ?>
      
    </tr>
    <?php
  }
  
  print '</table>';  
}

// Определяемся, что выводим в полях формы.
  
if ( $do == 'update-member' ) 
{
  $member = cleaner( $_POST );
}
else 
{
  $member = array(
    'nickname'  => '',
    'name'      => '',
    'city'      => '',
    'character' => '',
    'fandom'    => '',
  );  
}
    
?>

<p><a href='javascript:void(0)' onclick='changeDisplay( "member_form" )'>Добавить</a> &rarr;</p>
<div style="display:none" id='member_form'>
  <form action='' method='post'>
  
    <input type='hidden' name='do' value='create-member'>
    
    <table>
      <tr>
        <td>Ник</td>
        <td><input type='text' name='nickname' value='<?php print $member['nickname'] ?>'></td> 
      </tr>
      <tr>
        <td>Имя</td>
        <td><input type='text' name='name' value='<?php print $member['name'] ?>'></td> 
      </tr>
      <tr>
        <td>Город</td>
        <td><input type='text' name='city' value='<?php print $member['city'] ?>'></td> 
      </tr>
      
      <?php if ( $topic['characters_enabled'] ) { ?>
      <tr>
        <td>Имя персонажа</td>
        <td><input type='text' name='character' value='<?php print $member['character'] ?>'></td> 
      </tr>
      <tr>
        <td>Откуда персонаж</td>
        <td><input type='text' name='fandom' value='<?php print $member['fandom'] ?>'></td> 
      </tr>
      <?php } ?>

      <tr>
        <td colspan="2"><button style='width: 100%' type='submit'>Добавить</button></td>      
      </tr>
      
    </table>

  </form>
</div>